<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/include/adminHead.jsp" %>

	<script type="text/javascript" src="${jsUrl}/SmartEditorBasic2/js/HuskyEZCreator.js" charset="utf-8"></script>
  <TR>
    <TD height="%" valign="top">
      <TABLE width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
      
        <TBODY>
        <TR>
          <TD width="186" height="%" align="right" valign="top"><!-- Left Menu table 시작 --------------------------------> 
                        
            <TABLE width="176" height="100%" border="0" cellspacing="0" 
            cellpadding="0">
              <TBODY>
              <TR>
                <TD height="53"><IMG 
              src="${imgUrl}/left_top_title.gif"></TD></TR>
              <TR>
                <TD height="%" background="${imgUrl}/left_bg.gif" valign="top" 
                style="padding: 5px 0px 0px 5px;"><LINK href="${imgUrl}/admin.css" 
                  rel="stylesheet" type="text/css"> <!-- Menu table 끝 * css사용 해당메뉴의 페이지일때는  class="leftmenu_b", 해당 메뉴페이지가 아닐경우  class="leftmenu"로 사용--------------------------------> 
                  <TABLE width="150" style="margin-top: 10px;" border="0" 
                  cellspacing="0" cellpadding="0">
                    <TBODY>
					<c:forEach var = "menu" items="${menuList}">					
						<tr>
							<td height="25"><img src="${imgUrl}/left_icon.gif" border="0" align="absmiddle"/>
								<a class="leftmenu" href="javascript:goAdminBoardListMain(<c:out value="${menu.menuIndex}" />, <c:out value="${menu.menuType}" />)"><c:out value="${menu.menuName}" /></a>
							</td>
						</tr>				
					</c:forEach>
					<tr>
						<td height="25"><img src="${imgUrl}/left_icon.gif" border="0" align="absmiddle"/><a class="leftmenu" href="javascript:goAdminMenuList();">&nbsp;메뉴관리</a></td>
					</tr>
						</TBODY></TABLE></TD></TR></TBODY></TABLE><!-- Left Menu table 끝 --------------------------------> 
                    </TD>
          <TD width="%" align="right" valign="top" style="padding: 20px 10px 0px 0px;">
            <TABLE width="97%" border="0" cellspacing="0" cellpadding="0">
              <TBODY>
              <TR>
                <TD align="left" class="admin_title" background="${imgUrl}/title_bg.gif" 
                valign="middle"><IMG align="absmiddle" src="${imgUrl}/title_icon.gif"><c:out value="${menu.menuName}" /></TD></TR>                
              <TR>
                <TD height="20">&nbsp;</TD></TR>
              <TR>
                <TD>
                  <TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
                    <TBODY>
                    <TR>
                      <TD><!--리스트 테이블 시작-->
                      <form name="theForm" id="theForm" method="post" enctype="multipart/form-data">
                        <TABLE width="100%" bgcolor="#d9d9d9" border="0" 
                        cellspacing="1" cellpadding="0">
                          <TBODY>
                          <TR>
                            <TD height="1" bgcolor="#3f8bc9" colspan="2"></TD></TR>
                          <TR>
                            <TD width="10%" align="center" class="top_blue3" 
                            bgcolor="#eff3fa">제목</TD>
                            <TD align="left" class="top_blue3" style="padding-left: 10px;" 
                            bgcolor="#eff3fa"><INPUT name="title" class="inputText" style="width: 95%;" type="text" id="title" value="${boardView.title}"></TD></TR>
                          <TR>
                            <TD align="center" class="bold" 
                              bgcolor="#ffffff">이미지</TD>
                            <TD align="left" class="list_dark" style="padding-left: 10px;" 
                            bgcolor="#ffffff">
                              <input type='file' size='70' name='imgAttachmentFile' id="imgAttchmentFile" value="<c:out value="${boardView.imgAttachment }"/>"></TD></TR>
   						  </TD></TR>
                          <TR>
                            <TD align="center" class="bold" 
                              bgcolor="#ffffff">첨부파일</TD>
                            <TD align="left" class="list_dark" style="padding-left: 10px;" 
                            bgcolor="#ffffff">
                            <input type='file' size='70' name='attachmentFile' id="attchmentFile" value="<c:out value="${boardView.attachment }"/>">
                            </TD>
                          </TR>
                          <c:if test="${menu.menuIndex == 4}">
                          <TR>
                            <TD align="center" class="bold" 
                              bgcolor="#ffffff">링크</TD>
                            <TD align="left" class="list_dark" style="padding-left: 10px;" 
                            bgcolor="#ffffff">
                            <INPUT name="link" class="inputText" style="width: 95%;" type="text" id="link" value="${boardView.link}">
                            </TD>
                          </TR>
                          </c:if>
                          <TR>
                          
                            <TD style="padding: 10px;" bgcolor="#ffffff" colspan="2">
                            <INPUT name="ishtml" type="hidden" value="Y">
                             <TEXTAREA class="input1" id="contents" name="contents" style="width: 95%; height: 250px; display: none;"><c:out value="${boardView.contents }"/>
					                                                            </TEXTAREA>
					                                                                <SCRIPT type="text/javascript">
					                                                                var oEditors = [];
					                                                                var imagepath = "/resources/images";
					                                                                nhn.husky.EZCreator.createInIFrame({
					                                                                    oAppRef      : oEditors,
					                                                                    elPlaceHolder: "contents",
					                                                                    sSkinURI     : "${jsUrl}/SmartEditorBasic2/SEditorSkinEditorOnly.html",
					                                                                    fCreator     : "createSEditorInIFrame"
					                                                                });
					                                                                insertIMG = function (getId, fname) {
					                                                                    var sHTML = "<img src=/resources/board/" + fname + "' style='cursor:hand;' border='0'>";
					                                                                    oEditors.getById[getId].exec("PASTE_HTML", [sHTML]);
					                                                                };
					                                                        </SCRIPT>
                            <input type="hidden" name="menuIndex" id="menuIndex" value="${menu.menuIndex}">
                            <input type="hidden" name="menuType" id="menuType" value="${menu.menuType}">
                            <input type="hidden" name="textID" id="textID" value="${boardView.textID}">
                            <input type="hidden" name="mode" id="mode" value="${mode}">
                        </TD></TR></TBODY></TABLE></form><!--리스트 테이블 끝-->               
                            </TD></TR>
                    <TR>
                      <TD height="35" align="right">
                        <img src="${imgUrl}/btn_submit.gif" border="0" hspace="3" onClick="goRegist();" style="cursor:hand;">
                      	<img src="${imgUrl}/btn_list.gif" border="0" onClick="goBoardList();" style="cursor:hand;">
                      	</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
<form style="display:none;" id="frm" name="frm" method="post">
<input type="hidden" name="msg" id="msg" value="${msg}">
</form>
<script type="text/javascript">
	var msg = $("#msg").val();
	if(msg != '') {
		alert(msg);
		goBoardList();
	}
	function goAdminBoardListMain(type, menuType) {
	// type = 1 공지사항
		// type = 2 최신판례
		// type = 3 최신법령
		// type = 4 A항목
		// type = 5 B항목
		// type = 6 C항목
		// type = 7 D항목
		// type = 8 E항목
		// type = 9 F항목
		// type = 10 G항목
		// type = 11 H항목
		$("#menuIndex").val(type);
		var url;
		
		if (menuType == 0) {
			url = "/admin/adminBoardMain";
		} else {
			url = "/admin/adminBoard2Main";
		}
					
		$("#theForm").attr("action", url);
		$("#theForm").submit();
		
	}

	function goBoardList() {
	  var menuIndex = $("#menuIndex").val();
	  var menuType = $("#menuType").val();
	  goAdminBoardListMain(menuIndex, menuType);
	}
	
	function goRegist() {
	var title = $("#title").val();
	if(title == '') {
		alert('제목을 입력하세요.');
		$('#title').focus();
		return;
	}
	oEditors.getById["contents"].exec("UPDATE_IR_FIELD", []); 
	
	var content = $("#contents").val();
	if(content == '') {
		alert("내용을 입력하세요.");
		$('#contents').focus();
		return;
	}
	var usePoint = $("#usePoint").val();
	if(usePoint == '') {
		alert("구매포인트 입력하세요.");
		$('#usePoint').focus();
		return;
	}
	
	$("#theForm").attr("action", "/admin/adminRegistBoard");
	$("#theForm").submit();
	}
	function isNum(obj){ 
	  var val=obj.value;
	
		re=/[^0-9]/gi;
		if(re.test(val)) {
			alert('숫자만 입력가능합니다.');
			obj.value = "";
			obj.focus();
			return;
		}
	}
	
	var goAdminMenuList = function(){
		location.replace("/admin/adminMenuMain");
	};	
</script>
</BODY></HTML>
